package com.hxzy.mapper.system;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hxzy.dto.system.SysUserDTO;
import com.hxzy.entity.system.SysUser;
import com.hxzy.vo.system.user.UserAddDataVO;
import com.hxzy.vo.system.user.UserVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 用户
 */
@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> {

    void addUser(SysUser user);


    List<UserVO> selectAll(SysUserDTO userDTO);

    @Insert(value = "insert into sys_user_role(user_id,role_id) values (#{id},#{roleId})")
    void addUserRole(@Param(value = "id") Long id,@Param(value = "roleId") Long roleId);

    @Select(value = "select id,dept_name as name from sys_dept")
    List<UserAddDataVO> findDeptName();

    @Select(value = "select id,role_name as name from sys_role")
    List<UserAddDataVO> findRoleName();

    @Select(value = "select id,post_name as name from sys_post")
    List<UserAddDataVO> findPostName();

    UserVO findUser(Long id);

    @Update(value = "update sys_user_role   set  role_id=#{roleId} where user_id=#{id}")
    void updateUserRole(@Param(value = "id") Long id,@Param(value = "roleId") Long roleId);

    List<UserVO> findTreeUser(Long id);
}
